Package edu.uky.ai.csp.kr
Class Constraint
java.lang.Object
edu.uky.ai.csp.kr.Constraint
- Direct Known Subclasses:
EqualsConstraint,NotEqualsConstraint
public abstract class Constraint
extends java.lang.Object
A constraint specifies requirements that any solution to the problem must meet. This is the abstract superclass of all constraints.
For simplicity, we assume that all constraints are binary.
Constraints are not symmetric. In other words, for two variable V1 and V2 and some relation *, (V1 * V2) does not imply (V2 * V1).
- Author:
- Stephen G. Ware
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Constraint(Variable left, Variable right)Constructs a new constraint object. -
Method Summary
Modifier and Type Method Description protected abstract booleantestValues(Solution solution, java.lang.Object left, java.lang.Object right)A helper method for testing values which is defined for each new kind of constraint.
-
Field Details
-
Constructor Details
-
Constraint
Constructs a new constraint object.- Parameters:
left- the left hand side of the constraintright- the right hand side of the constraint
-
-
Method Details
-
testValues
protected abstract boolean testValues(Solution solution, java.lang.Object left, java.lang.Object right)A helper method for testing values which is defined for each new kind of constraint.- Parameters:
solution- the candidate solution, which provides context for the testleft- the value for the left variableright- the value for the right variable- Returns:
- false if these values would violate the constraint, true otherwise
-